package main

import (
	"fmt"
	"github.com/shopspring/decimal"
	"math/big"
)

/*
* Author: JacksonCoder
* CreateTime: 2025-11-15
 */

func main(){
	// 表示 123.45 元	=> 存储为 12345分
	var amountInCents int64 = 12345;
	fmt.Println("金额: ", amountInCents)
	fmt.Printf("amountInCents: %d\n ", amountInCents)
	//fmt.Printf("amountInCents: %s\n ", amountInCents)
	fmt.Printf("类型: %T\n ", amountInCents)

	price := new(big.Rat).SetFrac64(12345,100)  // 123.45
	taxRate := new(big.Rat).SetFrac64(13,100)   // 13%
	total := new(big.Rat).Mul(price,taxRate)
	fmt.Printf("总金额 :%v  类型是:%T\n",total,total)


	price1, _ := decimal.NewFromString("123.45")
	taxRate1, _ := decimal.NewFromString("0.13")
	Total := price1.Mul(taxRate1).Round(2) // 保留两位小数
	fmt.Printf("总金额 :%v  类型是:%T\n",Total,Total)
}
